﻿/*	
	stencil - action script 3 isometric game engine.

	http://code.google.com/p/stencilas3/
	
	Copyright (c) 2010 Max Zhuravkov, All Rights Reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy of
	this software and associated documentation files (the "Software"), to deal in
	the Software without restriction, including without limitation the rights to
	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
	of the Software, and to permit persons to whom the Software is furnished to do
	so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
package stencil.core.engine 
{
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	/**
	 * ...
	 * @author Max Zhuravkov
	 */
	public interface IGrid {
		
		/**
		 * Cell width.
		 */
		function set cellWidth(value:Number):void;
		
		function get cellWidth():Number;
		
		/**
		 * Cell height.
		 */
		function set cellHeight(value:Number):void;
		
		function get cellHeight():Number;
		
		/**
		 * Grid cell with the least coordinates.
		 */
		function get offset():Point;
		
		/**
		 * Global coordinates of the offset cell.
		 */
		function get globalOffset():Point;
		
		function redraw(cells:Array, container:Sprite, absolutePositions:Boolean = false):void;
		
		//update(offset:Point);
		
		/**
		 * Calculates the nearest cell position to the given point.
		 * 
		 * @param	point	the global coordinates.
		 * @param	local	whether passed coordinates are local or not.
		 * @param	result	the result.
		 */
		function calculateNearestPosition(point:Point, local:Boolean, result:Position):void;
		
		/**
		 * Calculates global-space coordinates of the cell at (x,y) position.
		 * 
		 * @param	x	x coordinate.
		 * @param	y	y coordinate.
		 * @param	local	whether the calculated coordinates should be local or not.
		 * @param	result	the result.
		 * 
		 */
		function calculateCellPosition(x:Number, y:Number, local:Boolean, result:Point):void;
		
		/**
		 * Calculates global-space coordinates of the cell at (x,y,z) position.
		 * 
		 * @param	position	the coordinates.
		 * @param	local	whether the calculated coordinates should be local or not.
		 * @param	result	the result.
		 */
		function calculateCellPositionAt(position:Position, local:Boolean, result:Point):void;
		
		/**
		 * Calculates global-space coordinates of the cell at (x,y) position.
		 * 
		 * @param	position	the coordinates.
		 * @param	local	whether the calculated coordinates should be local or not.
		 * @param	result	the result.
		 */
		function calculateCellPositionAtPoint(position:Point, local:Boolean, result:Point):void;
		
		
		/**
		 * Returns the nearest cell position to the given point.
		 * 
		 * @param	point	the global-space coordinates.
		 * @param	local	whether passed coordinates are local or not.
		 * @param	result	the result.
		 */
		function getNearestPosition(point:Point, local:Boolean):Position;
		
		/**
		 * Calculates cell position using the given coordinates.
		 * 
		 * @param	x	x coordinate.
		 * @param	y	y coordinate.
		 * @param	local	whether the calculated coordinates should be local or not.
		 * @param	result	the result.
		 */
		function getCellPosition(x:Number, y:Number, local:Boolean):Point
		
		/**
		 * Calculates cell position using the given coordinates.
		 * 
		 * @param	position	the coordinates.
		 * @param	local	whether the calculated coordinates should be local or not.
		 */
		function getCellPositionAt(pos:Position, local:Boolean):Point;
		
		/**
		 * Calculates cell position using the given coordinates.
		 * 
		 * @param	position	the coordinates.
		 * @param	local	whether the calculated coordinates should be local or not.
		 */
		function getCellPositionAtPoint(pos:Point, local:Boolean):Point;
		
		/**
		 * Returns the minimum rectangular area (global-space coordinates) that surrounds the given rectangle (grid coordinates).
		 * 
		 * @param	rect	rectangualr area (grid coordinates).
		 * 
		 */
		function getRect(rect:Rectangle):Rectangle;
	}
	
}